﻿using System;
using System.Windows;
using Box2DX.Dynamics;
using Box2DX.Common;

namespace Expression.Samples.Physics
{
	/*
	public sealed class DistanceJointBehavior : JointBehavior<DistanceJoint>
	{
		public static readonly DependencyProperty LengthProperty = DependencyProperty.Register(
			"Length",
			typeof(double),
			typeof(DistanceJointBehavior),
			new PropertyMetadata(
				new PropertyChangedCallback(LengthChanged)));
		public static readonly DependencyProperty HostAnchorPointProperty = DependencyProperty.Register(
			"HostAnchorPoint",
			typeof(Point),
			typeof(DistanceJointBehavior),
			new PropertyMetadata(
				new PropertyChangedCallback(HostAnchorPointChanged)));
		public static readonly DependencyProperty AnchorAnchorPointProperty = DependencyProperty.Register(
			"AnchorAnchorPoint",
			typeof(Point),
			typeof(DistanceJointBehavior),
			new PropertyMetadata(
				new PropertyChangedCallback(AnchorAnchorPointChanged)));

		public double Length
		{
			get { return (double)this.GetValue(DistanceJointBehavior.LengthProperty); }
			set { this.SetValue(DistanceJointBehavior.LengthProperty, value); }
		}

		public Point HostAnchorPoint
		{
			get { return (Point)this.GetValue(DistanceJointBehavior.HostAnchorPointProperty); }
			set { this.SetValue(DistanceJointBehavior.HostAnchorPointProperty, value); }
		}

		public Point AnchorAnchorPoint
		{
			get { return (Point)this.GetValue(DistanceJointBehavior.AnchorAnchorPointProperty); }
			set { this.SetValue(DistanceJointBehavior.AnchorAnchorPointProperty, value); }
		}

		private static void LengthChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
		{
			DistanceJointBehavior distanceJointBehavior = (DistanceJointBehavior)obj;
			distanceJointBehavior.RefreshJoint();
		}

		private static void HostAnchorPointChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
		{
			DistanceJointBehavior distanceJointBehavior = (DistanceJointBehavior)obj;
			distanceJointBehavior.RefreshJoint();
		}

		private static void AnchorAnchorPointChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
		{
			DistanceJointBehavior distanceJointBehavior = (DistanceJointBehavior)obj;
			distanceJointBehavior.RefreshJoint();
		}

		private Vector2 HostAnchorVector2
		{
			get
			{
				return new Vector2((float)this.HostAnchorPoint.X - 0.5f, -0.5f + (float)this.HostAnchorPoint.Y);
			}
		}

		private Vector2 AnchorAnchorVector2
		{
			get
			{
				return new Vector2((float)this.AnchorAnchorPoint.X - 0.5f, -0.5f + (float)this.AnchorAnchorPoint.Y);
			}
		}

		protected override JointDef InitializeJoint()
		{
			if (this.HostBody != null && this.AnchorBody != null)
			{
				DistanceJointDef distanceJointDef = new DistanceJointDef();
				distanceJointDef.Initialize(this.HostBody, this.AnchorBody, this.HostBody.GetWorldPoint(this.HostAnchorVector2), this.AnchorBody.GetWorldPoint(this.AnchorAnchorVector2));
				distanceJointDef.Length = (float)this.Length;
				return distanceJointDef;
			}
			return null;
		}
	}*/
}
